﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem
{
    public partial class ProductDetail : System.Web.UI.Page
    {
        public static DataTable dt;
        public static int id;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    if (Request.QueryString["idcolor"] == null)
                    {
                        id = Convert.ToInt32(Request.QueryString["ID"].ToString());
                        dt = DAL.DCollector.DBCollector.Instance.StoredProcedureGetTableByID("tbl_Product", id, "selectordetailproduct");
                    }
                    else
                    {
                        id = Convert.ToInt32(Request.QueryString["ID"].ToString());
                        string idcolor = Request.QueryString["idcolor"].ToString();
                        dt = DAL.DCollector.DBCollector.Instance.StoredProcedureGetTableByID("tbl_Product", Convert.ToInt32(idcolor), "selectordetailproductcolor");
                    }
                    if (Session["handbook"] != null && Session["handbook"].ToString().Contains(id.ToString()) == false)
                    {
                        Session["handbook"] += id.ToString() + ",";
                        string[] temp = Session["handbook"].ToString().Split(',');
                        if (temp.Length > 20)
                        {
                            // So tay day
                            Session["handbook"] = "";
                            for (int i = 1; i < temp.Length - 1; i++)
                            {
                                Session["handbook"] += temp[i] + ",";
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect("Error.aspx");
                }
            }

        }
    }
}